#!/usr/bin/env php
<?php

# A worker to resize an image sent in the workload.

$worker= new GearmanWorker();
$worker->addServer('127.0.0.1', 4730);
$worker->addFunction('resize', 'resize_callback');
while (@$worker->work());
 
function resize_callback($job)
{
  $thumb = new Imagick();
  $thumb->readImageBlob($job->workload());
  $thumb->scaleImage(200, 150);
  return $thumb->getImageBlob();
}

?>
